/**
 * ump注解,动态处理ump配置
 * Copyright (C), 2018 store
 * Encoding: UTF-8
 * Date: 19-9-17 上午9:56
 * History:
 */
package com.swak.frame.ratelimit.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.core.annotation.AliasFor;

import com.swak.frame.command.annotation.SwakExecutionType;
import com.swak.frame.command.annotation.SwakFallback;
import com.swak.frame.ratelimit.event.RateAlarmEvent;
import com.swak.frame.ratelimit.event.RateLimitAlarmEvent;

@Documented
@Target({java.lang.annotation.ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@SwakFallback
public @interface RateLimit {

    String key() default "";

    @AliasFor("value")
    int qps() default -1;

    @AliasFor("qps")
    int value() default -1;

    String retCode() default "";

    String desc() default "";

    /** 限流兜底方法 {@link SwakFallback#fallbackMethod} **/
    @AliasFor(annotation = SwakFallback.class)
    String fallbackMethod() default "";

    /** 限流类型 {@link SwakFallback#async} **/
    @AliasFor(annotation = SwakFallback.class)
    abstract SwakExecutionType async() default SwakExecutionType.SYNCHRONOUS;

    abstract Class<? extends RateAlarmEvent>[] event() default {RateLimitAlarmEvent.class};
}
